#!/usr/bin/env python
#

import os

from bible.TheHolyBible import *
import bible.util.HolyBibleFetch

from google.appengine.api import urlfetch

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext import db
from google.appengine.ext.webapp import template


class MainHandler(webapp.RequestHandler):
  def get(self):
    f = open("bible_chapter.list")
    i = 1;
    # for line in f:
    #   self.response.out.write('<h1>%s[%s]</h1>' % (i, line))
    #   for j in range(int(line)):
    #     self.response.out.write('%s %s' % (i, j))
    #     bible.util.HolyBibleFetch.getGAEScripts(self, i, j)
    lines = bible.util.HolyBibleFetch.getScripts(self, "GAE", 66, 2)
    self.response.out.write("<ol>\n")
    for line in lines:
      self.response.out.write("<li>%s</li>\n" % line)
    self.response.out.write("</ol>\n")
      

    # script = BibleScript("KEB", "GEN", 1, 1, "First, God made the world")
    # self.response.out.write('%s<br />' % script.version)
    # self.response.out.write('%s<br />' % script.book)
    # self.response.out.write('%s<br />' % script.chapter)
    # self.response.out.write('%s<br />' % script.verse)
    # self.response.out.write('%s<br />' % script.text)
    # bible.util.HolyBibleFetch.getBooks(self)


def main():
  application = webapp.WSGIApplication([('/', MainHandler)
                                        , ('/read', ReadHandler)]
                                       , debug=True)
  util.run_wsgi_app(application)


if __name__ == '__main__':
  main()



